package com.scwatch.core.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.Objects;
import com.scwatch.common.util.Dates;

import javax.persistence.*;
import java.util.Date;

/**
 *视频库
 * @author gjl
 *
 */
@Entity
@Table(name = "cms_videolib")
public class Videolib implements java.io.Serializable {
    private static final long serialVersionUID = 1L;

    public Videolib() {
    }

    private Integer id;
    /**
     * 视频名称
     */
    private String name;
    /**
     * 创建时间
     */
    private Date createDate;
    /**
     * 视频长度
     */
    private String duration;

    /**
     * 开始时间
     */
    private String startTime;

    /**
     *码率 单位kb
     */
    private String bitrate;

    /**
     * 编码格式
     */
    private String vcodec;

    /**
     * 视频格式
     */
    private String vformat;

    /**
     * 分辨率
     */
    private String resolution;


    /**
     * 音频编码
     */
    private String acodec;

    /**
     * 音频采样频率
     */
    private String asamplerate;

    /**
     * 视频文件大小
     */
    private String size;

    /**
     * 时长 秒
     */
    private String playTime;


    /**
     * cdn播放地址
     */
    private String cdnurl;

    /**
     * 存储地址
     */
    private String path;/**


     * 站点
     */
    private Site site;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "f_site_id", nullable = false)
    @JsonIgnore
    public Site getSite() {
        return site;
    }

    public void setSite(Site site) {
        this.site = site;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Videolib)) {
            return false;
        }
        Videolib that = (Videolib) o;
        return Objects.equal(id, that.id);
    }

    @Id
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "name", length = 50)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "creation_time")
    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Column(name = "Duration", length = 50)
    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    @Column(name = "start", length = 50)
    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    @Column(name = "bitrate", length = 50)
    public String getBitrate() {
        return bitrate;
    }

    public void setBitrate(String bitrate) {
        this.bitrate = bitrate;
    }

    @Column(name = "vcodec", length = 50)
    public String getVcodec() {
        return vcodec;
    }

    public void setVcodec(String vcodec) {
        this.vcodec = vcodec;
    }
    @Column(name = "vformat", length = 50)
    public String getVformat() {
        return vformat;
    }

    public void setVformat(String vformat) {
        this.vformat = vformat;
    }

    @Column(name = "resolution", length = 50)
    public String getResolution() {
        return resolution;
    }

    public void setResolution(String resolution) {
        this.resolution = resolution;
    }

    @Column(name = "acodec", length = 50)
    public String getAcodec() {
        return acodec;
    }

    public void setAcodec(String acodec) {
        this.acodec = acodec;
    }

    @Column(name = "asamplerate", length = 50)
    public String getAsamplerate() {
        return asamplerate;
    }

    public void setAsamplerate(String asamplerate) {
        this.asamplerate = asamplerate;
    }

    @Column(name = "size", length = 50)
    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    @Column(name = "play_time", length = 50)
    public String getPlayTime() {
        return playTime;
    }

    public void setPlayTime(String playTime) {
        this.playTime = playTime;
    }

    @Column(name = "cdnurl", length = 2000)
    public String getCdnurl() {
        return cdnurl;
    }

    public void setCdnurl(String cdnurl) {
        this.cdnurl = cdnurl;
    }

    @Column(name = "path", length = 2000)
    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @Transient
    public String getCreateDateStr(){
        return Dates.formatDate(this.createDate,"yyyy-MM-dd HH:mm:ss");
    }
}
